package reflect;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import org.junit.Test;
import org.omg.CORBA.PUBLIC_MEMBER;

public class Demo3 {
//反射
	@Test
 public void test1() throws Exception{
	 Person person = new Person();
	Class clazz= Class.forName("reflect.Person");
	
	 Method method= clazz.getMethod("eat", null);
	 method.invoke(person, null);
	 }
	
	
	 @Test
	 public void test2() throws Exception{
		 Person person2= new Person();
		 Class clazz2= Class.forName("reflect.Person");
		 
		 
	 }
	//反射main方法
	 @Test 
	 public void test5() throws Exception{
		 
		 Class class1 = Class.forName("reflect.Person");
		 Method method1 = class1.getMethod("main", String[].class);
		 method1.invoke(null,(Object)new String[]{"1","2"} );
		 
		 
	 }
	 

}
